﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using xTeam.HengLe.Enums;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace xTeam.Hengle.Helper
{
    public static class StringExtendFun
    {
        /// <summary>
        /// 订单状态
        /// </summary>
        /// <param name="orderState"></param>
        /// <returns></returns>
        public static string OrderState(int orderState)
        {
            string strHtml = "";
            switch (orderState)
            {
                case (int)xTeam.HengLe.Enums.OrderState.UnPay:
                    strHtml = "未支付";
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.WAIT_BUYER_PAY:
                    strHtml = "未支付成功";
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.WAIT_SELLER_SEND_GOODS:
                    strHtml = "买家已付款";
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.WAIT_BUYER_CONFIRM_GOODS:
                    strHtml = "卖家已发货";
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.TRADE_FINISHED:
                    strHtml = "完成";
                    break;  
            }
            return strHtml;
        }

        /// <summary>
        /// 订单状态(管理员查看)
        /// </summary>
        /// <param name="orderState"></param>
        /// <returns></returns>
        public static string OrderStateForManage(int orderState)
        {
            string strHtml = "";
            switch (orderState)
            {
                case (int)xTeam.HengLe.Enums.OrderState.UnPay:
                    strHtml = "未支付";
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.WAIT_BUYER_PAY:
                    strHtml = "未支付成功";
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.WAIT_SELLER_SEND_GOODS:
                    strHtml = "买家已付款";
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.WAIT_BUYER_CONFIRM_GOODS:
                    strHtml = "等待买家确认到货";
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.TRADE_FINISHED:
                    strHtml = "完成";
                    break;
            }
            return strHtml;
        }

        /// <summary>
        /// 订单付款链接
        /// </summary>
        /// <param name="url"></param>
        /// <param name="orderState"></param>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public static string PayLink(UrlHelper Url, int orderState,string orderId)
        {
            string strHtml = string.Empty;
            switch (orderState)
            {
                case (int)xTeam.HengLe.Enums.OrderState.UnPay:
                    strHtml = string.Format("<a href=\"{0}\" target=\"_blank\" >在线支付</a>", Url.Action("Pay", "Alipay", new { orderId = orderId }));;
                    break;
                case (int)xTeam.HengLe.Enums.OrderState.WAIT_BUYER_PAY:
                    strHtml = string.Format("<a href=\"{0}\" target=\"_blank\" >在线支付</a>", Url.Action("Pay", "Alipay", new { orderId = orderId }));;
                    break;
            }
            return strHtml;
        }
    }
}
